package com.hnas.ecard.mapper;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.hnas.core.mapper.Mapper;
import com.hnas.ecard.orm.Commodit;
import com.hnas.ecard.service.dto.DTOCommodit;

public class CommoditMapper extends Mapper<DTOCommodit,Commodit>{

    private static CommoditMapper mapper;

	
	private CommoditMapper(){
		super(DTOCommodit.class,Commodit.class);
	}
	
	public static CommoditMapper getInstance(){
		if(mapper == null){
			mapper = new CommoditMapper();
		}
		return mapper;
	}
	
	public DTOCommodit mapToValue(Commodit vo){
		DTOCommodit dto = new DTOCommodit();
		BeanUtils.copyProperties(vo, dto);
		return dto;
	}
	
	public List<DTOCommodit> mapToValue(List<Commodit> list){
		List<DTOCommodit> dtoList = new ArrayList<DTOCommodit>();
		for(Commodit vo : list){
			DTOCommodit dto = mapToValue(vo);
			dtoList.add(dto);
		}
		return dtoList;
	}
}
